
//209.长度最小的子数组
class Solution {
    public:
        int minSubArrayLen(int target, vector<int>& nums) {
            //经典的滑动窗口问题
            int n=nums.size();
            int left=0;
            int ret=INT_MAX,tmp=0;  //
            for(int right=0;right<n;right++)
            {
                tmp+=nums[right];
                while(tmp>=target)
                {
                    ret=min(ret,right-left+1);
                    tmp-=nums[left++];
                }  
            }
            return ret==INT_MAX?0:ret;
        }
    };
    